package smb.controller;

import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import smb.vo.*;
import smb.service.SectionService;

import java.util.List;

@RestController
@RequestMapping("/section")
@AllArgsConstructor
public class SectionController {
    private SectionService sectionService;

    @GetMapping("/{id}")
    public CourseSection getSection(@PathVariable String id) {
        return sectionService.getSection(id);
    }

    @GetMapping("/{id}/student")
    public List<StudentScore> getStudents(@PathVariable String id, @RequestParam(defaultValue = "id") String order) {
        return sectionService.getStudents(id, order);
    }

    @PostMapping("/{sectionId}/student/{studentId}/score")
    public void postScore(@PathVariable String sectionId, @PathVariable String studentId, @RequestBody ScoreVo scoreVo) {
        sectionService.postScore(sectionId, studentId, scoreVo);
    }

    @GetMapping("/{id}/distribution")
    public ScoreDistribution getDistribution(@PathVariable String id) {
        return sectionService.getDistribution(id);
    }
}
